package com.quick.mq.serviceImpl;

import com.quick.common.Component.ExchangeType;
import com.quick.common.service.IMQService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@DubboService
public class MQServiceImpl implements IMQService {
    @Autowired
   private RabbitTemplate rabbitTemplate;

    public static final String DEFAULT_EXCHANGE = "topicExchange";
    private static final String DEFAULT_ROUTING_KEY = "call_car.queue";
    @Override
    public void sendMessage(String message) {
        rabbitTemplate.convertAndSend(DEFAULT_EXCHANGE, DEFAULT_ROUTING_KEY, message);
    }

    @Override
    public void sendMessage(String routingKey,String message ) {
        rabbitTemplate.convertAndSend(DEFAULT_EXCHANGE, routingKey, message);
    }

    @Override
    public void sendMessage(ExchangeType exchange,String routingKey,String message) {
        rabbitTemplate.convertAndSend(exchange.toString(), routingKey, message);
    }

}
